package com.wtx.chapter05;

/**
 * @description: 数组求和递归
 * @author: wtx
 * @createDate: 2020/5/21
 */
public class Sum {

    public static int sum( int[] arr ){
        return sum(arr,0);
    }
    private static int sum(int[] arr, int l){

        if (l==arr.length)
            return 0;
        else
            return arr[l] + sum(arr,l+1);  //将原来的问题，转化为更小的同一问题
    }
}
